home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / C / Applications / Cheat II / original / cheatMenus.c < prev    next >
Text File  |  1995-09-04  |  3KB  |  138 lines

  1. /*****
  2.  * cheatMenus.c
  3.  *
  4.  *
  5.  *****/
  6.  
  7. #include "cheatMenus.h"
  8. #include "cheatWindow.h"
  9. #include "ResRefs.h"
  10. #include "main.h"
  11. #include "cheat.h"
  12. #include "cheatpreffile.h"
  13. #include "cheatfile.h"
  14. #include "error.h"
  15. #include "showhelp.h"
  16.  
  17. #define kchecksaves false
  18.  
  19. MenuHandle    appleMenu, fileMenu, editMenu;
  20.  
  21. void SetUpMenus(void)
  22.  
  23. {
  24.     Handle menuBar;
  25.  
  26.     menuBar = GetNewMBar(rMenuBar);                        /* read menus into new menu list */
  27.     SetMenuBar(menuBar);                                /* set to the current menu list */
  28.     DisposHandle(menuBar);
  29.     
  30.     appleMenu = GetMHandle(mApple);
  31.     fileMenu = GetMHandle(mFile);
  32.     editMenu = GetMHandle(mEdit);
  33.     AddResMenu(appleMenu, 'DRVR');                /* add DA names to Apple menu */
  34.  
  35.     DrawMenuBar();
  36. }
  37. /* end SetUpMenus */
  38.  
  39.  
  40. /****
  41.  *  AdjustMenus()
  42.  *
  43.  *    Enable or disable the items in the Edit menu if a DA window
  44.  *    comes up or goes away. Our application doesn't do anything with
  45.  *    the Edit menu.
  46.  *
  47.  ****/
  48.  
  49. int enable (MenuHandle menu, short item, short ok);
  50.  
  51. void AdjustMenus(void)
  52. {
  53.     register WindowPeek wp = (WindowPeek) FrontWindow();
  54.     short kind = wp ? wp->windowKind : 0;
  55.     Boolean DA = kind < 0;
  56.     
  57.     enable(editMenu, 1, DA);
  58.     enable(editMenu, 3, DA);
  59.     enable(editMenu, 4, DA);
  60.     enable(editMenu, 5, DA);
  61.     enable(editMenu, 6, DA);
  62.     
  63. }
  64.  
  65. static
  66. enable(MenuHandle menu, short item, short ok)
  67. {
  68.     if (ok)
  69.         EnableItem(menu, item);
  70.     else
  71.         DisableItem(menu, item);
  72. }
  73.  
  74.  
  75. /*****
  76.  * HandleMenu(mSelect)
  77.  *
  78.  *    Handle the menu selection. mSelect is what MenuSelect() and
  79.  *    MenuKey() return: the high word is the menu ID, the low word
  80.  *    is the menu item
  81.  *
  82.  *****/
  83. #define BASE_RES_ID        500
  84. #define BASE_PICT_ID    1000
  85.  
  86. void HandleMenu (long mSelect)
  87.  
  88. {
  89.     int            menuID = HiWord(mSelect);
  90.     int            menuItem = LoWord(mSelect);
  91.     Str255        name;
  92.     GrafPtr        savePort;
  93.     WindowPeek    frontWindow;
  94.     
  95.     switch (menuID)
  96.       {
  97.       case    mApple:
  98.           if (menuItem == iAbout) {
  99.               //Alert(rAboutAlrt, nil);
  100.         Show_help( BASE_RES_ID, BASE_RES_ID, BASE_PICT_ID,
  101.         (StringPtr)"\pCheat II help", (StringPtr)"\pTitle page");
  102.           }
  103.           else {
  104.             GetPort(&savePort);
  105.             GetItem(appleMenu, menuItem, name);
  106.             OpenDeskAcc(name);
  107.             SetPort(savePort);
  108.         }
  109.         break;
  110.     
  111.       case    mFile:
  112.         switch (menuItem) {
  113.             case iQuit:
  114.                 timeToQuit = true;
  115.                 break;
  116.             default: break;
  117.         }
  118.         break;
  119.                   
  120.       case    mEdit:
  121.     //    if (!SystemEdit(menuItem-1))
  122.     //      ;
  123.     /*    if (FrontWindow() == cheatWindow)
  124.             switch (menuItem) {
  125.                 case iCut: DlgCut((DialogPtr) cheatWindow); break;
  126.                 case iCopy: DlgCopy((DialogPtr) cheatWindow); break;
  127.                 case iPaste: DlgPaste((DialogPtr) cheatWindow); break;
  128.                 case iClear: DlgDelete((DialogPtr) cheatWindow); break;
  129.                 default: verify(false); break;
  130.             } */
  131.         break;
  132.         
  133.         default: break;
  134.       }
  135. }
  136. /* end HandleMenu */
  137.  
  138.